package com.boot.web;

import com.boot.bean.GpsInfoBean;
import com.boot.service.GpsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.HashSet;
import java.util.Set;

/**
 * Created by xudi on 19/8/16.
 */
@Controller
@EnableAutoConfiguration
public class SimpleController {

    @Autowired
    GpsService gpsService;

    @RequestMapping(method = RequestMethod.GET)
    @ResponseBody
    public Object list(@RequestParam String jwd){
        return gpsService.queryGpsInfo(jwd);
    }

    @RequestMapping(method = RequestMethod.POST)
    @ResponseBody
    public Object insert(@RequestBody GpsInfoBean vo){
        return gpsService.addGpsInfo(vo.getUserId(),vo.getJwd());
    }

    @RequestMapping(method = RequestMethod.PUT)
    @ResponseBody
    public Object update(@RequestBody GpsInfoBean vo){
        return gpsService.updateGpsInfo(vo.getUserId(),vo.getJwd());
    }

    public static void main(String[] args) {
        SpringApplication app = new SpringApplication(SimpleController.class);
        app.setWebEnvironment(true);
        Set<Object> set = new HashSet<>();
        set.add("classpath:spring-config.xml");
        app.setSources(set);
        app.run(args);
    }
}
